home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2156 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  47 lines

  1. Path: maximus.East.DELFIN.COM!news
  2. From: Mike_Kapfer@notes.east.delfin.com
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Mouse Routines using C/C++
  5. Date: 19 Jan 1996 14:38:53 GMT
  6. Organization: Delfin Systems
  7. Message-ID: <4doadt$149@maximus.East.DELFIN.COM>
  8. References: <Pine.ULT.3.91.960118140647.27317A-100000@wpi.WPI.EDU>
  9. Reply-To: Mike_Kapfer@notes.east.delfin.com
  10. NNTP-Posting-Host: maximus.East.DELFIN.COM
  11. X-Newsreader: IBM NewsReader/2 v1.2.5
  12.  
  13. In <Pine.ULT.3.91.960118140647.27317A-100000@wpi.WPI.EDU>, Jon Day <jonday@wpi.edu> writes:
  14. >I have some simple routines to implement a mouse handler is assembler but 
  15. >nothin in C or C++. Can anyone provide me with example code on how to set 
  16. >up an interrupt handler for the mouse using only C? 
  17. >
  18.  
  19. This is probably off topic so expect a bunch of flames.  :)
  20.  
  21. Control of the mouse is very specific to the operating system/environment.  
  22. In DOS, you handle the mouse through interrupts (int86 call).  In Windows, 
  23. there are C APIs to handle control of the mouse.
  24.  
  25. Here is an example of how you would set up the registers and call int86 on a
  26. DOS machine ... the function is read_mouse and comes from "The C Programmers
  27. Toolkit" book by Jack Purdum (a pretty good entry level set of routines):
  28.  
  29. void read_mouse ( int *row, int *col, int *button )
  30. {
  31. /* This function returns the mouse position in row and col */
  32. /* And the status of the buttons */
  33.  
  34. union REGS ireg ;
  35.  
  36. ireg.x.ax = 0x03 ;       /* Load 0x03 in ax register for mouse pos and status */
  37. int86 ( 0x33, &ireg, &ireg ) ;  /* Call interrupt */
  38. *button = ireg.x.bx ;    
  39. *col = ireg.x.cx ;
  40. *row = ireg.x.dx ;
  41. }
  42. ===
  43. Michael Kapfer          Phone: (703) 758-0190 x2150
  44.  
  45. Internet:  Mike_Kapfer@notes.east.delfin.com
  46. For PGP public key, finger mkapfer@east.delfin.com
  47.